<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增任务')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <div style="font-size:20px ">电子集团创新项目情况表</div>
    <div style="height:300px">
        <iframe id="excelIframe" src='/demo/table/filling' width='100%'>
        </iframe>
    </div>
    <div>
        <div>审核意见</div>
        <div class="col-sm-10">
            <input type="text" class="form-control">
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: layout-latest-js" />
<th:block th:include="include :: ztree-js" />
<script th:inline="javascript">
    var prefix = ctx + "demo/table"
    $("#form-task-add").validate({
        focusCleanup: true
    });
    //任务执行人
    var executor=[]
    var enclosure=[]

    $(function () {
        queryDeptTree()
    });


    function queryDeptTree() {
        var url = ctx + "gs/company/selectExecutor";
        var options = {
            url: url,
            expandLevel: 2,
            onClick:zOnClick
        };
        function zOnClick(event, treeId, treeNode) {
            var node=0
            if (executor.length<1) {
                executor.push(treeNode.id)
                $("#executor").append("<span style='margin: 0px 5px'>"+treeNode.name+"</span>")
            }else{
                for (var i=0;i<executor.length;i++){
                    if (treeNode.id!=executor[i]){
                        node++
                    }
                }
                if (node==executor.length){
                    executor.push(treeNode.id)
                    $("#executor").append(treeNode.name)
                }
            }
            console.info(executor)
        }
        $.tree.init(options);
    }



    function submitHandler() {
        // if ($('#filePath')[0].files[0] == null) {
        //     $.modal.alertWarning("请先选择文件路径");
        //     return false;
        // }
        // var files=$('#filePath')[0].files
        // for (var i=0;i<files.length;i++){
        //     var formData = new FormData();
        //     formData.append('file', $('#filePath')[0].files[i]);
        //     $.ajax({
        //         url: ctx + "common/upload/",
        //         type: 'post',
        //         cache: false,
        //         data: formData,
        //         processData: false,
        //         contentType: false,
        //         dataType: "json",
        //         success: function(result) {
        //
        //             enclosure.push(result.url)
        //             var dataList={
        //                 "taskName":$("#taskName").val(),
        //                 "taskStartTime":$("#taskStartTime").val(),
        //                 "taskEndTime":$("#taskEndTime").val(),
        //                 "lagging":$("#lagging").val(),
        //                 "taskType":$("#taskType").val(),
        //                 "auditMethod":$("#auditMethod").val(),
        //                 "enclosure":enclosure,
        //                 "executor":executor
        //             }
        //             console.info(dataList)
        //
        //
        //
        //             $.ajax({
        //                 url: prefix + "/add",
        //                 type: "post",
        //                 dataType: "json",
        //                 contentType: 'application/json',
        //                 data:JSON.stringify({
        //                     "gsTask":dataList
        //                 }),
        //                 beforeSend: function () {
        //                     $.modal.loading("正在处理中，请稍后...");
        //                     $.modal.disable();
        //                 },
        //                 success: function (result) {
        //                     // $.operate.successCallback(result);
        //                     //销售单
        //                         let url = prefix + "/template";
        //                         $.modal.open("导入报表模板", url);
        //
        //                 }
        //             });
        //             // console.info(enclosure)
        //             // $.operate.successCallback(result);
        //         }
        //     });
        //
        // }

        let url = prefix + "/template";
        $.modal.openFull("导入报表模板", url);

        // if ($.validate.form()) {
        //     $.operate.save(prefix + "/add", $('#form-task-add').serialize());
        // }
    }

    $("input[name='taskStartTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='taskEndTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
</script>
</body>
</html>